package ysq.xyg.base.extend.ehcache;

import org.apache.commons.lang3.StringUtils;
import ysq.xyg.base.util.SpringApplicationContextUtil;
import ysq.xyg.sys.model.po.SysConfig;

import java.util.List;

/**
 * 缓存工具
 *
 * @author taocongcong
 * @create 2019-04-11 18:11
 */
public class EhcacheUtils {

    private static EhCacheService ehCacheService = (EhCacheService) SpringApplicationContextUtil.getBean("ehCacheService");

    public static SysConfig selectSysConfigList(String code) {
        SysConfig sysConfig = null;
        List<SysConfig> sysConfigList = ehCacheService.selectSysConfigList();
        if (sysConfigList != null && sysConfigList.size() > 0) {
            for (SysConfig entity : sysConfigList) {
                if (StringUtils.equals(code, entity.getCode())) {
                    sysConfig = entity;
                }
            }
        }
        return sysConfig;
    }
}
